import numpy as np
import matplotlib.pyplot as plt
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import precision_score, recall_score, f1_score
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split

if '__main__' == __name__:
    data_path = r'../../../../large_data/机器一月考/'
    x = np.loadtxt(data_path + 'jacketdata.txt', delimiter=',')
    y = np.loadtxt(data_path + 'jacketlabels.txt', delimiter=',')
    cls_ids = np.unique(y)
    print(cls_ids)
    n_cls = len(cls_ids)

    scaler = StandardScaler()
    x = scaler.fit_transform(x)

    x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.7, random_state=0)
    cls = MLPClassifier([20, 10], 'logistic', alpha=0.1, max_iter=200)
    cls.fit(x_train, y_train)
    print(f'layers count = {cls.n_layers_}')
    print(f'output coutn = {cls.n_outputs_}')
    print(f'coefficients = {cls.coefs_}')
    print(f'intercepts = {cls.intercepts_}')
    print(f'Training score = {cls.score(x_train, y_train)}')
    print(f'Testing score = {cls.score(x_test, y_test)}')
